package ihm.actions.character_creator;

import ihm.views.character_creator.CharacterCreator;

import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;

import javax.swing.ImageIcon;

import systems.rpgBuilder.Classe;

public class ClasseSelectedAction
implements ItemListener {

  private CharacterCreator charCreatorFrame;

  public ClasseSelectedAction(CharacterCreator source)
  {
    this.charCreatorFrame = source;
  }

  @Override
  public void itemStateChanged(ItemEvent e) {
    Classe selectedClasse= (Classe)  this.charCreatorFrame.getClasseComboBox().getSelectedItem();
    if(selectedClasse != null)
    {
      this.charCreatorFrame.getClasseIconLabel().setIcon(new ImageIcon(selectedClasse.getImagePath()));
      if(this.charCreatorFrame.getClasseComboBox().isEnabled())
        this.charCreatorFrame.getValidateButton().setEnabled(true);
    }
  }

}
